<div class="boxer">
<div class="box">
		<div class="catname">
			<h2 class="jiaose-list-ico">人员管理列表</h2>
			<a href="add">新增人员</a>
		</div>
		<div class="search user-search">
		<form action="/user/list" method="get">
				<i class="ico">搜索条件</i>
				<input type="text" class="t" placeholder="用户名"  name="account" value="{{.Query.account}}"/>
				<select name="status" id="search-qy">
				<option value="0">选择状态</option>
				{{range $index, $elem := .StatusList}}
					{{if eq $.Status $index}}
					<option value="{{$index}}" selected>{{$elem}}</option>	
					{{else}}
					<option value="{{$index}}">{{$elem}}</option>	
					{{end}}
				{{end}}
				</select>
				<input type="text" class="t" placeholder="人员姓名" name="name" value="{{.Query.name}}"/>
				<select name="roles" id="search-roles">
					<option value="0">选择角色</option>
					{{range .RoleList}}
						{{if eq $.Roles .Id}}
						<option value="{{.Id}}" selected>{{.Name}}</option>
						{{else}}
						<option value="{{.Id}}">{{.Name}}</option>
						{{end}}
					{{end}}
				</select>
				<input type="text" class="t" placeholder="工号" name="job_number" value="{{.Query.job_number}}"/>
				<input type="text" class="t" placeholder="职务"  name="duty" value="{{.Query.duty}}"/>
				<input type="submit" class="btn" value="搜 索" />
				<input type="reset" class="btn" value="重 置" />
				<br class="clr" />
		</form>

		</div>
		<div class="default-table-box">
			<div class="default-table">
				<table border="0" cellspacing="0" cellpadding="0" width="100%">
					<tr>
						<th width="75">序号</th>
						<th>用户名</th>
						<th width="120">状态</th>
						<th width="150">人员姓名</th>
						<th width="140">角色名称</th>
						<th width="140">工号</th>
						<th width="140">职务</th>
						<th width="200">最后更新时间</th>
						<th width="120">操作</th>
					</tr>
					{{range .Page.List}}
			          <tr style="text-align:center;">
			            <td>{{.Id}}</td>
			            <td>{{.Account}}</td>
						<td>
						{{if eq .Status 1}}
						<font color="green">启用</font>
						{{else}}
						<font color="red">禁用</font>
						{{end}}
						</td>
						<td>{{.Name}}</td>
						<td>{{.Password}}</td>
			            <td>{{.JobNumber}}</td>
						<td>{{.Duty}}</td>
						<td>{{date .Time "Y-m-d H:i:s"}}</td>
						<td>
						<a href="/user/edit/{{.Id}}" class="operation jsxg" title="修改"></a>
						<a href="/user/password/{{.Id}}" class="operation psd" title="修改密码"></a>
						{{if ne .Account $.safeAccount}}
						<a href="javascript:;"  userid="{{.Id}}" class="operation del" title="删除"></a>
						{{end}}
						</td>
						<td></td>
			          </tr>
					 {{end}}
				</table>
			</div>
			<div class="default-pages margin_ten">
				<form method="get" class="pageForm">
					<input type="hidden" name="PageNo" value="{{.Page.PageNo}}" total="{{.Page.TotalPage}}"/>
					<input type="hidden" name="SizePage" value="{{.SizePage}}"/>
				</form>
				<div>共{{.Page.TotalCount}}条记录，每页&nbsp;<em><b>{{.SizePage}}</b><i>^</i><ul><li data-num="10">10</li><li data-num="20">20</li><li data-num="40">40</li></ul></em>条</div>
				<ul>
					<li><span>{{.Page.PageNo}}/{{.Page.TotalPage}}页</span></li>
					<li><a href="javascript:void(0)" id="first">首页</a></li>
					<li><a href="javascript:void(0)" id="pre">上一页</a></li>
					<li><a href="javascript:void(0)" id="next" total="{{.Page.TotalPage}}">下一页</a></li>
					<li><a href="javascript:void(0)" id="last" pageNo="{{.Page.TotalPage}}">尾页</a></li>
					<li><span>跳转至第</span></li>
					<li><input type="text" id="jump"/></li>
					<li><span>页</span></li>
				</ul>

			</div>
		</div>
	</div>
	</div>
	<script type="text/javascript">
jQuery(function($){
	
	$(".default-pages div em").toggle(function(){
		$(this).find("ul").show();
	},function(){
		$(this).find("ul").hide();
	});
	
	$("#jump").on("blur",function(){
		var jump=$(this).val()
		if(jump<=parseInt($("#next").attr("total"))&&jump>=1){
			$("[name=PageNo]").val(jump);
			$(".pageForm").attr("action",window.location).submit()
		}else{
			$(this).val("")
		}
	});

	//首页
	$("#first").on("click",function(){
		$("[name=pageNo]").val(1);
		$("[name=size]").val({{.size}});
		$("#pageForm").submit()
	});
	//尾页
	$("#last").on("click",function(){
		$("[name=pageNo]").val($(this).attr("pageNo"));
		$("#pageForm").attr("action",window.location).submit()
	});
	//上一页
	$("#pre").on("click",function(){
		if(parseInt($("[name=PageNo]").val())-1>=1){
			$("[name=PageNo]").val(parseInt($("[name=PageNo]").val())-1);
			$(".pageForm").attr("action",window.location).submit()
		}
	});
	//下一页
	$("#next").on("click",function(){
		if(parseInt($("[name=PageNo]").val())+1<=parseInt($("[name=PageNo]").attr("total"))){
			$("[name=PageNo]").val(parseInt($("[name=PageNo]").val())+1);
			$(".pageForm").attr("action",window.location).submit()
		}
	});
	$(".default-pages div em").toggle(function(){
		$(this).find("ul").show();
	},function(){
		$(this).find("ul").hide();
	});

	$(".default-pages div ul li").on("click",function(){
		$(".default-pages div em b").text($(this).data("num"));
		$("[name=PageNo]").val(1);
		$("[name=SizePage]").val($(this).data("num"));
		$(".pageForm").attr("action",window.location).submit();
	});

	$(".default-table").on("click","a.del",function(){
		var id=$(this).attr("userid")
    	layer.confirm('确认删除当前这个角色吗？删除后无法恢复！', {
    	  title: '删除',
		  btn: ['是的','取消'], //按钮
		  yes: function(index){
		  	var this_id = $(this).data("id");
			window.location.href="/user/delete/"+id
		  	layer.close(index);
		  }
		});
    });
	
	nku.droplist.config({'theme':'win7'}).play('search-qy');
	nku.droplist.config({'theme':'win7'}).play('search-roles');

});
</script>